//
//  VipCardInfoTableViewCell.m
//  fitnessmanage
//
//  Created by wujian on 2017/12/7.
//  Copyright © 2017年 zongquankeji. All rights reserved.
//

#import "VipCardInfoTableViewCell.h"

@interface VipCardInfoTableViewCell()

@property(nonatomic,strong)NSDictionary *hashDict;

@end

@implementation VipCardInfoTableViewCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.hashDict = @{@"绑定会员":@"carddetail_icon_peo",@"消费记录":@"carddetail_icon_record",@"适用场馆":@"carddetail_icon_home",@"实体卡号":@"carddetail_icon_card"};
        
        
        /**
         标题图片
         */
        UIImageView *titleImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:titleImageView];
        self.titleImageView = titleImageView;
        
        /**
         标题
         */
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.text = @"标题";
        titleLabel.font = MidBigFont;
        titleLabel.textColor = CSColorFromRGB(0x212121);
        [self.contentView addSubview:titleLabel];
        self.titleLabel = titleLabel;
        
        /**
         详情
         */
        UILabel *detailLabel = [[UILabel alloc] init];
        detailLabel.text = @"温柔阳光";
        detailLabel.font = SmallFont;
        detailLabel.textColor = CSColorFromRGB(0xb3b3b3);
        [self.contentView addSubview:detailLabel];
        self.detailLabel = detailLabel;                
        
        /**
         右侧
         */
        UIImageView *rightImageView = [[UIImageView alloc] init];
        rightImageView.image = [UIImage imageNamed:@"xiayibu"];
        [self.contentView addSubview:rightImageView];
        self.rightImageView = rightImageView;
        
        [self setConstraints];
    }
    
    return self;
}

-(void)setConstraints{
    
    [self.titleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.mas_equalTo(self.contentView);
        
        make.left.mas_equalTo(self.contentView).offset(15);
    }];
    
    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(self.titleImageView.mas_right).offset(15);
        
        make.bottom.mas_equalTo(self.contentView.mas_centerY).offset(2);
    }];
    
    [self.detailLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(self.titleLabel);
        
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(4);
    }];
 
    /**
     右侧
     */
    [self.rightImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.contentView);
        
        make.right.mas_equalTo(self.contentView).offset(-10);
    }];
}


/**
 设置标题
 */
-(void)setTitle:(NSString *)title{
    
    self.titleImageView.image = [UIImage imageNamed:[self.hashDict objectForKey:title]];
    
    self.titleLabel.text = title;
}

- (void)drawRect:(CGRect)rect
{
    CGContextRef context =UIGraphicsGetCurrentContext();
    
    CGContextBeginPath(context);
    
    CGContextSetLineWidth(context,1.0);//线宽度
    
    CGContextSetStrokeColorWithColor(context,LineBackGroundColor.CGColor);
    
    CGContextMoveToPoint(context,self.titleLabel.left,rect.size.height);
    
    CGContextAddLineToPoint(context,SCREEN_WIDTH - 20,rect.size.height);
    
    CGContextStrokePath(context);
}

@end
